﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HKEA.CMS.Core.Utility
{
    public class PageParam
    {
        /// <summary>
        /// 当前第N页
        /// </summary>
        public int CurrentPage { get; set; }
        /// <summary>
        /// 每页显示记录条数
        /// </summary>
        public int PageSize { get; set; }
        /// <summary>
        /// 总记录条数
        /// </summary>
        public int Count { get; set; }
        /// <summary>
        /// 记录的起始索引
        /// </summary>
        private int recordStart;
        /// <summary>
        /// 总页数
        /// </summary>
        public int PageCount
        {
            get
            {
                int count = 0;
                count = (int)Math.Ceiling((double)Count / (double)PageSize);
                return count;
            }
        }
        /// <summary>
        /// 是否为最后一页
        /// </summary>
        public bool HasNextPage
        {
            get
            {
                bool hasNext = false;
                if (CurrentPage < PageCount)
                    hasNext = true;
                return hasNext;
            }
        }
        /// <summary>
        /// 是否为第一页
        /// </summary>
        public bool HasPrePage
        {
            get
            {
                bool hasPre = false;
                if (CurrentPage > 1)
                    hasPre = true;
                return hasPre;
            }
        }

        /// <summary>
        /// 起始记录
        /// </summary>
        public int RecordStart
        {
            get
            {
                recordStart = (CurrentPage - 1) * PageSize;
                if( recordStart < 0)
                    return 0;
                return recordStart;
            }
        }

    }
}
